package com.hans.myscanner.Scanner.Activity;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.hans.myscanner.R;
import com.hans.myscanner.adapter.HistoryRecordAdapter;
import com.hans.myscanner.entity.ContactEntity;
import com.hans.myscanner.entity.RecordEntity;

import java.util.ArrayList;
import java.util.List;

public class HistorySubActivity extends BaseSubActivity {

    private ListView historyListView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_history);
        findView();
        initView();
    }

    @Override
    protected void findView() {
        historyListView= (ListView) findViewById(R.id.history_listView);
    }

    @Override
    protected void initView() {
        HistoryRecordAdapter historyRecordAdapter=new HistoryRecordAdapter(HistorySubActivity.this,getRecordData());
        historyListView.setAdapter(historyRecordAdapter);
        historyListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                startActivity(new Intent(HistorySubActivity.this,QRMakeActivity.class));
            }
        });

    }

    private List<RecordEntity> getRecordData(){
        List<RecordEntity> recordEntityList =new ArrayList<>();
        ContactEntity contactEntity = new ContactEntity("李二狗","1388888888");
        recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.TEXT,"测试文本", RecordEntity.RECORD_FROM.MAKE));
        recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.CONTACT,contactEntity, RecordEntity.RECORD_FROM.SCAN));
        recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.URL,"http://www.baidu.com", RecordEntity.RECORD_FROM.MAKE));
        recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.TEXT,"哈哈啊哈", RecordEntity.RECORD_FROM.SCAN));
        recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.CONTACT,contactEntity, RecordEntity.RECORD_FROM.SCAN));
        recordEntityList.add(new RecordEntity(RecordEntity.RECORD_TYPE.URL,"http://www.google.com", RecordEntity.RECORD_FROM.MAKE));
        return recordEntityList;
    }
}
